<template>
    <div class="img-card" oncontextmenu="return false;">
        <div class="img-card-content">
            <div
                class="img-card-img"
                :class="{h156: !item.pb}"
                @mouseenter="playvideo"
                @mouseleave="playImg"
            >
                <a :href="item.url">
                    <img :src="item.img" v-if="showImg" />
                    <video
                        :src="item.video"
                        autoplay="autoplay"
                        loop="loop"
                        width="100%"
                        muted="muted"
                        v-if="!showImg"
                    ></video>
                </a>
            </div>
            <div class="img-card-tips">
                <div class="img-card-title">{{item.title}}</div>
                <div class="img-card-icon" v-if="item.showIcon">
                    <span
                        class="iconfont icon-star-thr start-icon"
                        style="color: #fea231;"
                        v-if="item.start"
                    ></span>
                    <span class="iconfont icon-star-thr start-icon" v-if="!item.start"></span>
                    <span class="iconfont icon-wodeqiye qiye-icon" v-if="item.type == 1"></span>
                    <span class="iconfont icon-myperson1 person-icon" v-if="item.type == 0"></span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: "img-card",
    props: ["item"],
    data() {
        return {
            showImg: true,
            vedioHeight: 0
        };
    },
    methods: {
        playImg() {
            this.showImg = true;
        },
        playvideo(e) {
            this.vedioHeight = e.relatedTarget.clientHeight;
            this.showImg = Boolean(this.item.video) ? false : true;
        }
    }
};
</script>

<style scoped lang="less">
video {
    margin: 0;
    padding: 0;
}
.h156 {
    overflow: hidden;
    // height: 156px
}

.img-card {
    padding-right: 6px;
    padding-left: 6px;
    margin-bottom: 18px;

    &-content {
        border: 1px solid #eee;
    }

    .img-card-img {
        width: 100%;
    }

    a {
        color: #000000;

        &:hover {
            text-decoration: none;
        }
    }

    .img-card-tips {
        display: flex;
        justify-content: space-between;
        padding: 8px;
        padding-bottom: 0px;
        // padding: 0 8px;
        font-size: 14px;
        line-height: 24px;

        .img-card-icon span {
            cursor: pointer;
        }

        .thr-icon {
            font-size: 18px;
            line-height: 24px;
            position: relative;
            top: -2px;
            padding: 0 2px;
            display: inline-block;
        }

        .qiye-icon {
            color: #ec5246;
            font-size: 24px;
            line-height: 24px;
            padding: 0 2px;
            display: inline-block;
        }

        .person-icon {
            color: #fea231;
            font-size: 24px;
            line-height: 24px;
            padding: 0 2px;
            display: inline-block;
        }

        .start-icon {
            // color: #ec5246;
            color: #ccc;
            font-size: 19px;
            line-height: 24px;
            position: relative;
            top: -2px;
            padding: 0 2px;
            display: inline-block;
        }
    }
}
</style>